package com.example.raidball;




import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView.FindListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

public class Level_adapter extends BaseAdapter {
	
	private Context mContext;
	public String[] mThumbIds = {"1","2","3","4","5","6","7","8","9","10"};
	long[] scores;
	boolean[] isLvlLock;
            
	public Level_adapter(Context c, long[] score, boolean[] islvlLock) {
		mContext = c;
		scores=score;
		isLvlLock=islvlLock;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mThumbIds.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mThumbIds[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
       	 LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       	 convertView = inflater.inflate(R.layout.level_view, null);
        }
    	TextView nbLevel = (TextView)convertView.findViewById(R.id.nbLevel);
        String str = mThumbIds[position];
        nbLevel.setText(str);
        if(isLvlLock[position]==true){
        	ImageView imgLock = (ImageView) convertView.findViewById(R.id.lock);
        	imgLock.setImageResource(R.drawable.lock);
        	
        }
        else{

            TextView highScore = (TextView)convertView.findViewById(R.id.highScore);
            highScore.setText("High Score: "+scores[position]);
        }
		return convertView;
	}

}
